#ifndef COMMON_SORTEDIRECTORYTERATOT_H_
#define COMMON_SORTEDIRECTORYTERATOT_H_

#include <fermat/common/file.h>
#include <fermat/common/path.h>
#include <fermat/common/directory_iterator.h>
#include <deque>


namespace fermat {
	/*!
	* The SortedDirectoryIterator class is similar to
	* DirectoryIterator class, but places directories before files
	* and sorts content alphabetically.
	*/
class  SortedDirectoryIterator: public DirectoryIterator {
public:
	SortedDirectoryIterator();
		/// Creates the end iterator.

	SortedDirectoryIterator(const std::string& path);
		/// Creates a directory iterator for the given path.

	SortedDirectoryIterator(const DirectoryIterator& iterator);
		/// Creates a directory iterator for the given path.

	SortedDirectoryIterator(const File& file);
		/// Creates a directory iterator for the given file.

	SortedDirectoryIterator(const Path& path);
		/// Creates a directory iterator for the given path.

	virtual ~SortedDirectoryIterator();
		/// Destroys the DirsFirstDirectoryIterator.

	virtual SortedDirectoryIterator& operator ++();   // prefix

private:
	bool                       _is_finished;
	std::deque<std::string>    _directories;
	std::deque<std::string>    _files;

	void next();
		/// Take next item
	void scan();
		/// Scan directory to collect its children directories and files
};


} 

#endif 
